// pages/my/index/index.js
Page({

  data: {
    userInfo: {},
    levelInfo: {},
    cashTake: "",
    popup_show: false,
    iconList_1: [{
        name: "每日浏览",
        src: "https://www.linxiaobang.com.cn/miniprogram/image/ico_attestation_1@2x.png"
      },
      {
        name: "做任务",
        src: "https://www.linxiaobang.com.cn/miniprogram/image/ico_attestation_2@2x.png"
      },
      {
        name: "发动态",
        src: "https://www.linxiaobang.com.cn/miniprogram/image/ico_attestation_3@2x.png"
      },
      {
        name: "买卖商品",
        src: "https://www.linxiaobang.com.cn/miniprogram/image/ico_attestation_4@2x.png"
      },
    ],
    iconList_2: [{
        name: "饭团翻倍",
        src: "https://www.linxiaobang.com.cn/miniprogram/image/ico_privilege_1@2x.png"
      },
      {
        name: "饭团兑换特权",
        src: "https://www.linxiaobang.com.cn/miniprogram/image/ico_privilege_2@2x.png"
      },
      {
        name: "专属客服",
        src: "https://www.linxiaobang.com.cn/miniprogram/image/ico_privilege_3@2x.png"
      },
      {
        name: "合伙人优先权",
        src: "https://www.linxiaobang.com.cn/miniprogram/image/ico_privilege_4@2x.png"
      },
      {
        name: "提现更快",
        src: "https://www.linxiaobang.com.cn/miniprogram/image/ico_privilege_5@2x.png"
      },
      {
        name: "提现门槛低",
        src: "https://www.linxiaobang.com.cn/miniprogram/image/ico_privilege_6@2x.png"
      },
    ],
    msgNum: ""
  },
  onLoad: function (options) {},
  onShow: function () {
    this.setData({
      msgNum: !wx.getStorageSync("msgNum") ? 1 : false
    });
    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
      this.getTabBar().setData({
        selected: 3
      });
    }
    this.getUserInfo();
    this.getLevel();
    this.getMyCashTake();
  },
  onPullDownRefresh() {
    wx.showNavigationBarLoading();
    this.getUserInfo();
  },
  onShareAppMessage() {},
  getUserInfo() {
    getApp().globalData.http.userInfo().then(res => {
      this.setData({
        userInfo: res.data
      });
      wx.setStorageSync("userInfo", res.data);
      wx.stopPullDownRefresh();
      wx.hideNavigationBarLoading();
    });
  },
  getLevel() {
    getApp().globalData.http.userLevel().then(res => {
      this.setData({
        levelInfo: res.data
      });
    });
  },
  getMyCashTake() {
    getApp().globalData.http.myCashTake().then(res => {
      this.setData({
        cashTake: res.data.withdraw
      });
    });
  },
  navTo(e) {
    let path = e.currentTarget.dataset.path;
    wx.navigateTo({
      url: path,
    })
  },
  openPopup() {
    this.setData({
      popup_show: true
    });
  },
  popupClose() {
    this.setData({
      popup_show: false
    });
  },
  navTo(e) {
    wx.navigateTo({
      url: e.currentTarget.dataset.path,
    })
  },
  notOpen() {
    getApp().globalData.vant.toast("即将上线，敬请期待");
  },
  contact() {
    wx.openCustomerServiceChat({
      extInfo: {
        url: "https://work.weixin.qq.com/kfid/kfc51ce94a9f01103b7"
      },
      corpId: "ww0374dc0aaeebc87a",
      success(res) {}
    })
  }
})